Skip to content

feat(difs): Add Objectstore columns to ProjectDebugFile#117500

Merged
lcian merged 2 commits into
masterfrom
lcian/feat/objectstore-debug-files-migration
Jun 15, 2026
Merged

feat(difs): Add Objectstore columns to ProjectDebugFile#117500
lcian merged 2 commits into
masterfrom
lcian/feat/objectstore-debug-files-migration

Conversation

@lcian

@lcian lcian commented Jun 12, 2026

Copy link
Copy Markdown
Member

Adds new columns to house Objectstore-backed difs.
These will lose the file FK and gain the storage_path field.
In addition, we also need to add content_type, file_size and date_created, as those were previously fields of File.
Naturally, during the migration period, both of these need to be nullable, so we need to assert the invariants we know to be true at runtime.

Ref FS-364

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/migrations/1115_projectdebugfile_add_objectstore_columns.py

for 1115_projectdebugfile_add_objectstore_columns in sentry

--
-- Alter field file on projectdebugfile
--
SET CONSTRAINTS "sentry_projectdsymfile_file_id_bdf41a41_fk_sentry_file_id" IMMEDIATE; ALTER TABLE "sentry_projectdsymfile" DROP CONSTRAINT "sentry_projectdsymfile_file_id_bdf41a41_fk_sentry_file_id";
ALTER TABLE "sentry_projectdsymfile" ALTER COLUMN "file_id" DROP NOT NULL;
ALTER TABLE "sentry_projectdsymfile" ADD CONSTRAINT "sentry_projectdsymfile_file_id_bdf41a41_fk_sentry_file_id" FOREIGN KEY ("file_id") REFERENCES "sentry_file" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_projectdsymfile" VALIDATE CONSTRAINT "sentry_projectdsymfile_file_id_bdf41a41_fk_sentry_file_id";
--
-- Add field storage_path to projectdebugfile
--
ALTER TABLE "sentry_projectdsymfile" ADD COLUMN "storage_path" text NULL;
--
-- Add field content_type to projectdebugfile
--
ALTER TABLE "sentry_projectdsymfile" ADD COLUMN "content_type" text NULL;
--
-- Add field file_size to projectdebugfile
--
ALTER TABLE "sentry_projectdsymfile" ADD COLUMN "file_size" bigint NULL;
--
-- Add field date_created to projectdebugfile
--
ALTER TABLE "sentry_projectdsymfile" ADD COLUMN "date_created" timestamp with time zone NULL;

@lcian lcian force-pushed the lcian/feat/objectstore-debug-files-migration branch 2 times, most recently from 7c7b0ee to 0b95ff7 Compare June 12, 2026 09:28
lcian added 2 commits June 12, 2026 13:18
Add new nullable columns (storage_path, content_type, file_size,
date_created) and make the File FK nullable in preparation for
migrating debug files to Objectstore.
@lcian lcian force-pushed the lcian/feat/objectstore-debug-files-migration branch from 0b95ff7 to 4fe3b25 Compare June 12, 2026 11:18
@lcian lcian marked this pull request as ready for review June 12, 2026 12:50
@lcian lcian requested review from a team as code owners June 12, 2026 12:50
@lcian lcian requested review from a team June 12, 2026 12:50
Comment thread src/sentry/models/debugfile.py
Comment thread src/sentry/models/debugfile.py
@loewenheim

Copy link
Copy Markdown
Contributor

Is the idea behind making the file field nullable in the model and adding assertions that this way we save ourselves a migration? In principle, it would work just as well to only add the new columns and do the nullability separately, right?

@lcian

lcian commented Jun 12, 2026

Copy link
Copy Markdown
Member Author

Yeah @loewenheim, we could very well split this into 2 separate migrations, would it be preferable to do it that way?
It's my first time creating a migration, so I don't really know what factors should be considered.

The intention was not really to spare a migration, but to make the File nullable while at the same time introducing the alternative, as if this were an enum you add a variant to.
A ProjectDebugFile with a NULL File doesn't make too much sense to me, unless an alternative way to point to a file exists.

@loewenheim

Copy link
Copy Markdown
Contributor

If having two separate migrations isn't a concern, I would prefer it if the file field was made nullable at the point where it's actually possible for a debug file to have null there.

@lcian

lcian commented Jun 12, 2026

Copy link
Copy Markdown
Member Author

Yeah that makes sense, I'll change it.

@wedamija wedamija left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

migration lgtm

@lcian

lcian commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

I'm going to merge this as is, as making the File column nullable when it can actually be null would add more changes to #117502 where we add the write capability, which is already a large change.

@lcian lcian merged commit 8574547 into master Jun 15, 2026
85 of 86 checks passed
@lcian lcian deleted the lcian/feat/objectstore-debug-files-migration branch June 15, 2026 12:43
@linear-code

linear-code Bot commented Jun 15, 2026

Copy link
Copy Markdown

FS-364

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants